package com.boot2.core.kafka;

import com.boot2.core.utils.SerializeUtil;
import org.apache.kafka.common.serialization.Serializer;

import java.util.Map;

/**
 *
 * @ClassName: KafkaEncode
 * @Description: kafka消息编码
 * @author zhangweilin
 * @date 2017年11月9日 下午1:31:06
 *
 */
public class KafkaEncode implements Serializer<Object> {
	@Override
	public void configure(Map configs, boolean isKey) {

	}

	@Override
	public byte[] serialize(String topic, Object data) {
//		System.out.println("KafkaEncode: " + data);
		return SerializeUtil.serialize(data);
	}

	/*
	 * producer调用close()方法是调用
	 */
	@Override
	public void close() {
		System.out.println("EncodeingKafka is close");
	}
}